package cmd

import (
	"log"
	"longmen/server/config/global"
	"os"
	"runtime/debug"

	"github.com/spf13/cobra"
)

var configFile = "../../../config/app.properties"

var rootCmd = &cobra.Command{
	Use:   "crontab",
	Short: "cronjob server",
	Long:  `cronjob server`,
	PreRun: func(cmd *cobra.Command, args []string) {

	},
}

func Execute() {
	// 尝试捕获panic并保存到错误中
	defer func() {
		if r := recover(); r != nil {
			log.Println(r)
			debug.PrintStack()
		}
	}()
	global.AppName = "crontab"
	rootCmd.AddCommand(runServer)
	rootCmd.AddCommand(initCli)
	rootCmd.AddCommand(syncMQTT)
	rootCmd.AddCommand(initSharding)
	rootCmd.AddCommand(testCli)
	rootCmd.AddCommand(flashComp)
	rootCmd.AddCommand(testEsport)
	rootCmd.AddCommand(venue)
	rootCmd.AddCommand(initBBLineUp)
	rootCmd.AddCommand(testMatchCli)
	rootCmd.AddCommand(deleteMatchCli)
	rootCmd.AddCommand(recentCli)
	rootCmd.AddCommand(syncScoreCli)
	if err := rootCmd.Execute(); err != nil {
		os.Exit(1)
	}
}
